import React,{ Component } from 'react';
import { doAdd, doDel} from '../model/demo1' // 这种写法是不好的和外接有耦合，好的做法是外边通过props传进来
class Demo2 extends Component{
    constructor(props){
        super(props);
        this.store = this.props.store;
    }
    add = () =>{
        this.store.dispatch(doAdd(2))
    }
    del = () => {
        this.store.dispatch(doDel(2))
    }
    render(){
        const jq = this.store.getState().jq.num;
        return (<div>
            <input type="button" value="+" onClick={this.add} />
            <input type="button" value="-" onClick={this.del} />
            result:{jq}</div>)
    }
}

export default Demo2;